<template>
  <cwCommon :type="type" :financeData="form" @clear="clearForm" :name="cw">

  <el-form-item label="客户名称">
    <el-select v-model="form.ticket_id" placeholder="请选择客户" size="medium" @change="getTicket" style="width:500px;">
      <el-option v-for="(ticket,t) in ticketList" :key="t" :label="ticket.name" :value="ticket.id"></el-option>
    </el-select>
  </el-form-item>

    <el-form-item label="税号">
      <el-input v-model="ticket.batch_id" disabled></el-input>
    </el-form-item>

    <el-form-item label="地址">
      <el-input v-model="ticket.address" disabled></el-input>
    </el-form-item>

    <el-form-item label="电话">
      <el-input v-model="ticket.mobile" disabled></el-input>
    </el-form-item>

    <el-form-item label="开户行">
      <el-input v-model="ticket.bank" disabled></el-input>
    </el-form-item>

    <el-form-item label="账号">
      <el-input v-model="ticket.account" disabled></el-input>
    </el-form-item>

    <el-form-item label="开户行号">
      <el-input v-model="ticket.bank_number" disabled></el-input>
    </el-form-item>

    <el-form-item label="发票名称">
      <el-input v-model="form.name"></el-input>
    </el-form-item>

    <el-form-item label="发票金额">
      <el-input v-model="form.money" @focus="$cls" @blur="$fmoney" ></el-input>
    </el-form-item>

    <el-form-item label="发票类型">
      <el-select v-model="form.ticket_category" placeholder="请选择发票类型" size="medium" style="width:500px;" value-key="id">
        <el-option v-for="(cate,i) in ticketCategory" :key="i" :label="cate.value" :value="cate.id"></el-option>
      </el-select>
    </el-form-item>

    <el-form-item label="申请类别">
      <el-select v-model="form.ticket_type" placeholder="请选择申请类别" size="medium" style="width:500px;" value-key="id">
        <el-option v-for="(type,x) in ticketType" :key="x" :label="type.value" :value="type.id"></el-option>
      </el-select>
    </el-form-item>



  </cwCommon>
</template>

<script>
    import cwCommon from "./cwCommon";
    import {mapState} from 'vuex'
    import {getTicketInfo} from '@/apilist/Finance'
    export default {
        name: "cwTicket",
        data(){
            return {
                type: 5,
                form: {
                    name: '',
                    money: '0.00',
                    ticket_id: '',
                    ticket_category: '',
                    ticket_type: ''

                },
                ticket: {
                  batch_id: '',
                  address: '',
                  mobile: '',
                  bank: '',
                  account: '',
                  bank_number: '',
                },
              cw:'发票'
            }
        },
        components: {cwCommon},

        computed:{
            ...mapState("FinanceData",['ticketList','ticketType','ticketCategory']),
        },
        methods: {
            getTicket(){
                getTicketInfo({id: this.form.ticket_id}).then(res => {
                  this.ticket.batch_id = res.data.batch_id
                  this.ticket.address = res.data.address
                  this.ticket.mobile = res.data.mobile
                  this.ticket.bank = res.data.bank
                  this.ticket.account = res.data.account
                  this.ticket.bank_number = res.data.bank_number
                })
            },
            clearForm(){
              this.form.name = ''
              this.form.money = '0.00'
              this.form.ticket_id = ''
              this.form.ticket_category = ''
              this.form.ticket_type = ''
              this.ticket.batch_id = ''
              this.ticket.mobile = ''
              this.ticket.bank = ''
              this.ticket.account = ''
              this.ticket.bank_number = ''
            },
        },
    }
</script>

<style scoped>

</style>
